package cn.semcorp.zhuhaizj.quartzConfig;

import cn.semcorp.zhuhaizj.quartzJob.TobePlanJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzPlanConfiguration {

    @Bean
    public JobDetail showPlanJob(){
        return JobBuilder.newJob(TobePlanJob.class)
                .withIdentity("tobePlanJob")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger showPlanTrigger(){
        CronScheduleBuilder cron =
            CronScheduleBuilder.cronSchedule("0 0 */2 * * ? *");
        return TriggerBuilder.newTrigger()
                .withSchedule(cron)
                .withIdentity("showPlanTrigger")
                .forJob(showPlanJob())
                .build();
    }
}
